Thread: [Not Urgent at all] - Print from c++ Console doesn't work.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    17

    Question Print from c++ Console doesn't work.

    Hi. I have search the internet. and most of the solution I've got is similar to the code below.

    Problem is, It doesn't work for me.
    i've tested the exe on several PCs, it still doesn't work.
    Please help me to fix this.
    Thanks.

    Code:
    #include <iostream>
    #include <fstream>
    using namespace  std ;
    
    void main()
    {
    	cout<<"Start Printing..."<<endl;
    	ofstream printer;
    	const char EJECT = 0x0c; 
    	printer.open("LPT1");
    	if( !printer )
    	{
    		cerr << "Error! Could not print!";
    		exit(1);
    	}
    
    	printer<<"Hello World!\n"<<endl;
     	cout<<"Hello World, printed."<<endl;
    
    	printer<<EJECT;
    	printer.close();
    	cout<<"Done Printing."<<endl;
    }
    This is the error I had after I run the exe.
    --------------------------- C:\Documents and Settings\zerodevice\Desktop\printer.exe ---------------------------
    C:\Documents and Settings\zerodevice\Desktop\printer.exe
    This application has failed to start because the application configuration is incorrect.
    Reinstalling the application may fix this problem.
    --------------------------- OK ---------------------------

    I am certain my printer and driver works.
    Because they were able to print other documents.
    Last edited by zerodevice; 08-03-2006 at 11:49 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 11:05 AM
  2. How to print Right aligned Text in a console?
    By Aidman in forum C++ Programming
    Replies: 13
    Last Post: 03-09-2003, 10:43 PM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  4. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM
  5. Console Buffers, Why doesnt this work ?
    By richardnuk in forum C++ Programming
    Replies: 2
    Last Post: 02-01-2002, 04:24 PM